package gnv;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.widgets.Text;

public class Validation {
	
	
	public boolean verificaImporte(Text text, VerifyEvent event){
		// Assume you don't allow it
		event.doit = false;
		
		// Get the character typed
		char myChar = event.character;
		
		
		// Permitimos caracteres especiales ,' backspace, delete, space 
		if ((event.keyCode == '\u002E') || (event.keyCode == '\u0008') || 
				(event.keyCode == SWT.KEYPAD_DECIMAL) ||(Character.isDigit(myChar)) ){
			
			event.doit = true;
			return true;
			}
			
		
		return false;
	}

	
	public boolean verificaFecha(Text text, VerifyEvent event){
		// Assume you don't allow it
		event.doit = false;
		
		// Get the character typed
		char myChar = event.character;
		
		// Permitimos caracteres especiales ,' backspace, delete, space 
		if ((event.keyCode == '\u007F') || (event.keyCode == '\u0008') || 
				(event.keyCode == SWT.KEYPAD_SUBTRACT) || (Character.isDigit(myChar)) ){
			
			event.doit = true;
			return true;
			}
			
		
		return false;
	}
		
	
		
	
	
	
}
